package com.haiwei.poi.word.test;

import com.haiwei.poi.word.common.HaiweiDocumentGenerator;
import com.haiwei.poi.word.poi.HaiweiXWPFTableUtil;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;

import java.io.File;

/**
 * 1.
 *
 * @date: 2022-06-25
 * @version: 1.0
 * @author: karry@haiwei.com
 */
public class test4 {
    
    public static void main(String[] args) {
        try {
            final XWPFDocument document = HaiweiDocumentGenerator
                    .build(new File(FilePathUtils.getPath("44.docx")));
    
            final XWPFTable table = document.getTables().get(0);
    
            System.out.println("row.size:"+table.getNumberOfRows());
            // 插入一条数据
            XWPFTableRow sourceRow = table.getRow(0);
    
            HaiweiXWPFTableUtil.addAndCopyRows(table,sourceRow,2,3);
    
            final File file = new File(FilePathUtils.getPath("4444.docx"));
            HaiweiDocumentGenerator.toFile(document,file);
            System.out.println(file.getAbsolutePath());
        
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
